package com.burstly.lib.downloadtracker;

import android.content.Context;
import com.burstly.lib.feature.dtracker.IDownloadTracker;
import com.burstly.lib.network.request.DefaultRequestCallback;
import com.burstly.lib.util.LoggerExt;
import com.burstly.lib.util.Utils;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.concurrent.Callable;

public final class DownloadTrackingManager
  implements IDownloadTracker, Callable<Boolean>
{
  public static final String TAG = DownloadTrackingManager.class.getSimpleName();
  static Context sAppContext;
  static volatile boolean sDownloadInProgress;
  private static LoggerExt sLog;

  // ERROR //
  static boolean isFileExist(String paramString, Context paramContext)
  {
    // Byte code:
    //   0: aload_1
    //   1: aload_0
    //   2: invokevirtual 44	android/content/Context:openFileInput	(Ljava/lang/String;)Ljava/io/FileInputStream;
    //   5: astore 4
    //   7: aload 4
    //   9: invokestatic 50	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   12: iconst_1
    //   13: ireturn
    //   14: astore_3
    //   15: aconst_null
    //   16: invokestatic 50	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   19: iconst_0
    //   20: ireturn
    //   21: astore_2
    //   22: aconst_null
    //   23: invokestatic 50	com/burstly/lib/util/Utils:closeStream	(Ljava/io/Closeable;)V
    //   26: aload_2
    //   27: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   0	7	14	java/io/FileNotFoundException
    //   0	7	21	finally
  }

  public Boolean call()
    throws Exception
  {
    String str = Utils.getDeviceId(sAppContext);
    if (str != null)
    {
      boolean bool1 = isFileExist(str, sAppContext);
      boolean bool2 = false;
      if (!bool1)
        bool2 = true;
      return Boolean.valueOf(bool2);
    }
    return Boolean.valueOf(false);
  }

  // ERROR //
  public void sendDTRequestIfNeeded(Context paramContext)
    throws com.burstly.lib.exception.WrongThreadException
  {
    // Byte code:
    //   0: aload_0
    //   1: monitorenter
    //   2: aload_1
    //   3: invokevirtual 79	android/content/Context:getApplicationContext	()Landroid/content/Context;
    //   6: putstatic 56	com/burstly/lib/downloadtracker/DownloadTrackingManager:sAppContext	Landroid/content/Context;
    //   9: aload_1
    //   10: invokestatic 84	com/burstly/lib/constants/BurstlyProperties:initProperties	(Landroid/content/Context;)V
    //   13: invokestatic 87	com/burstly/lib/util/Utils:checkIsUiThread	()V
    //   16: aload_1
    //   17: invokestatic 92	com/burstly/lib/service/HostsProviderManager:init	(Landroid/content/Context;)V
    //   20: getstatic 34	com/burstly/lib/downloadtracker/DownloadTrackingManager:sLog	Lcom/burstly/lib/util/LoggerExt;
    //   23: ifnonnull +9 -> 32
    //   26: invokestatic 97	com/burstly/lib/util/LoggerExt:getInstance	()Lcom/burstly/lib/util/LoggerExt;
    //   29: putstatic 34	com/burstly/lib/downloadtracker/DownloadTrackingManager:sLog	Lcom/burstly/lib/util/LoggerExt;
    //   32: aload_1
    //   33: invokestatic 60	com/burstly/lib/util/Utils:getDeviceId	(Landroid/content/Context;)Ljava/lang/String;
    //   36: astore_3
    //   37: aload_3
    //   38: ifnonnull +19 -> 57
    //   41: getstatic 34	com/burstly/lib/downloadtracker/DownloadTrackingManager:sLog	Lcom/burstly/lib/util/LoggerExt;
    //   44: getstatic 27	com/burstly/lib/downloadtracker/DownloadTrackingManager:TAG	Ljava/lang/String;
    //   47: ldc 99
    //   49: iconst_0
    //   50: anewarray 5	java/lang/Object
    //   53: invokevirtual 103	com/burstly/lib/util/LoggerExt:logError	(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   56: pop
    //   57: aload_3
    //   58: ifnull +66 -> 124
    //   61: getstatic 105	com/burstly/lib/downloadtracker/DownloadTrackingManager:sDownloadInProgress	Z
    //   64: ifne +60 -> 124
    //   67: invokestatic 111	java/util/concurrent/Executors:newSingleThreadExecutor	()Ljava/util/concurrent/ExecutorService;
    //   70: astore 5
    //   72: aload 5
    //   74: aload_0
    //   75: invokeinterface 117 2 0
    //   80: invokeinterface 122 1 0
    //   85: checkcast 64	java/lang/Boolean
    //   88: invokevirtual 126	java/lang/Boolean:booleanValue	()Z
    //   91: ifeq +25 -> 116
    //   94: iconst_1
    //   95: putstatic 105	com/burstly/lib/downloadtracker/DownloadTrackingManager:sDownloadInProgress	Z
    //   98: aload_1
    //   99: aload_3
    //   100: getstatic 27	com/burstly/lib/downloadtracker/DownloadTrackingManager:TAG	Ljava/lang/String;
    //   103: new 128	com/burstly/lib/downloadtracker/DownloadTrackingManager$RequestCallback
    //   106: dup
    //   107: aload_1
    //   108: aload_3
    //   109: invokespecial 131	com/burstly/lib/downloadtracker/DownloadTrackingManager$RequestCallback:<init>	(Landroid/content/Context;Ljava/lang/String;)V
    //   112: invokestatic 137	com/burstly/lib/network/request/RequestManager:makeDownloadTrackRequest	(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Lcom/burstly/lib/network/request/IRequestCallback;)Lcom/burstly/lib/network/request/AbortableAsyncTask;
    //   115: pop
    //   116: aload 5
    //   118: invokeinterface 141 1 0
    //   123: pop
    //   124: aload_0
    //   125: monitorexit
    //   126: return
    //   127: astore 8
    //   129: aload 5
    //   131: invokeinterface 141 1 0
    //   136: pop
    //   137: goto -13 -> 124
    //   140: astore_2
    //   141: aload_0
    //   142: monitorexit
    //   143: aload_2
    //   144: athrow
    //   145: astore 6
    //   147: aload 5
    //   149: invokeinterface 141 1 0
    //   154: pop
    //   155: aload 6
    //   157: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   72	116	127	java/lang/Exception
    //   2	32	140	finally
    //   32	37	140	finally
    //   41	57	140	finally
    //   61	72	140	finally
    //   116	124	140	finally
    //   129	137	140	finally
    //   147	158	140	finally
    //   72	116	145	finally
  }

  private static class RequestCallback extends DefaultRequestCallback<String>
  {
    private static final String DNL_ERR_DB = "DNL_ERR_DB";
    private final Context mAppContext;
    private final String mFileName;

    RequestCallback(Context paramContext, String paramString)
    {
      this.mAppContext = paramContext;
      this.mFileName = paramString;
    }

    private static void writeFile(String paramString, Context paramContext)
    {
      try
      {
        OutputStreamWriter localOutputStreamWriter = new OutputStreamWriter(paramContext.openFileOutput(paramString, 0));
        localOutputStreamWriter.write(String.valueOf(Math.random()));
        localOutputStreamWriter.flush();
        localOutputStreamWriter.close();
        return;
      }
      catch (FileNotFoundException localFileNotFoundException)
      {
        DownloadTrackingManager.sLog.logThrowable(DownloadTrackingManager.TAG, localFileNotFoundException);
        return;
      }
      catch (IOException localIOException)
      {
        DownloadTrackingManager.sLog.logThrowable(DownloadTrackingManager.TAG, localIOException);
      }
    }

    public void onNoConnection()
    {
      DownloadTrackingManager.sDownloadInProgress = false;
    }

    public void onSuccessInBackground(String paramString)
    {
      if (!"DNL_ERR_DB".equals(paramString))
        writeFile(this.mFileName, this.mAppContext);
      DownloadTrackingManager.sDownloadInProgress = false;
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.downloadtracker.DownloadTrackingManager
 * JD-Core Version:    0.6.2
 */